import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getwidget/getwidget.dart';
import 'package:ichinesereader/controller/evaluation.dart';
import 'package:ichinesereader/pages/teacher/homeworkStepper.dart';
import 'package:ichinesereader/widgets/dialogs/simpleAlertDialog.dart';
import '../../controller/user.dart';
import '../../themes/appTheme.dart';
import '../dialogs/switchClassDialog.dart';

class FloatingActionButtonCreateEvaluationHomework extends StatelessWidget {
  FloatingActionButtonCreateEvaluationHomework({
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    EvaluationController _controller = Get.find();
    UserController _userController = Get.find();

    return Column(
      mainAxisAlignment: MainAxisAlignment.end,
      children: <Widget>[
        Container(
          height: 45,
          width: 45,
          child: FloatingActionButton(
            backgroundColor: Get.isDarkMode
                ? Theme.of(context).primaryColorDark.withOpacity(0.9)
                : AppTheme.colors.pinkBtn,
            foregroundColor:
                Get.isDarkMode ? Colors.black : AppTheme.colors.lightPink,
            heroTag: Text('createevaluationhomework0000'),
            tooltip: 'Create Homework'.tr,
            onPressed: () {
              if (_controller.selectedEvaluationBooks.length > 0) {
                Get.to(() => HomeworkSteps(
                      isNew: true,
                      books: _controller.selectedEvaluationBooks,
                    ));
              } else {
                showGeneralDialog(
                    context: context,
                    transitionDuration: Duration(milliseconds: 400),
                    pageBuilder: (bc, ania, anis) {
                      return SimpleAlertDialog(
                          title: 'No Book'.tr,
                          message:
                              'Please select at least one book to ASSIGN!'.tr);
                    });
              }
            },
            child: Obx(() {
              int? num;
              if (_controller.selectedEvaluationBooks.length > 0)
                num = _controller.selectedEvaluationBooks.length;

              if (num != null && num > 0) {
                return GFBadge(
                  child: Text('+$num'),
                  size: 32,
                );
              } else {
                return Icon(
                  Icons.assignment,
                  color:
                      Get.isDarkMode ? Colors.black : AppTheme.colors.lightPink,
                  size: 24,
                );
              }
            }),
            //splashColor: Colors.grey,
          ),
        ),
        SizedBox(height: 5),
        Visibility(
          visible: _userController.myClasses.isNotEmpty &&
              _userController.myClasses.length > 1,
          child: SizedBox(
            height: 45,
            width: 45,
            child: FloatingActionButton(
              backgroundColor:
                  Get.isDarkMode ? Colors.white : AppTheme.colors.orangeBtn,
              foregroundColor:
                  Get.isDarkMode ? Colors.black : AppTheme.colors.lightOrange,
              tooltip: 'Switch Class'.tr,
              heroTag: 'switchclass8899',
              onPressed: () {
                showGeneralDialog(
                    context: context,
                    transitionDuration: Duration(milliseconds: 400),
                    pageBuilder: (bc, ania, anis) {
                      return SwitchTeacherClassDialog();
                    });
              },
              child: Icon(
                Icons.class_outlined,
                color:
                    Get.isDarkMode ? Colors.black : AppTheme.colors.lightOrange,
                size: 24,
              ),
              elevation: 9.0,
            ),
          ),
        ),
        // SizedBox(height: 5),
        // SizedBox(
        //   height: 45,
        //   width: 45,
        //   child: FloatingActionButton(
        //     heroTag: 'balbalhome8899',
        //     backgroundColor: Theme.of(context).primaryColorDark,
        //     foregroundColor: Get.isDarkMode
        //         ? Colors.black
        //         : Theme.of(context).primaryColorLight,
        //     tooltip: 'Home Page'.tr,
        //     onPressed: () {
        //       Get.delete<ReportsController>();
        //       Get.offAndToNamed('/teacher/home');
        //     },
        //     child: Icon(
        //       Icons.home_outlined,
        //       color:
        //           Get.isDarkMode ? Colors.black : Get.theme.primaryColorLight,
        //       size: 28,
        //     ),
        //   ),
        // ),
      ],
    );
  }
}
